

clear

use "$data/survey1_clean.dta", clear

gen bin_mort = 1 if perceived_mortality <=2
replace bin_mort = 3.5 if perceived_mortality >2 & perceived_mortality <=5
replace bin_mort = 7.5 if perceived_mortality >5 & perceived_mortality <=10
replace bin_mort = 15 if perceived_mortality >10 & perceived_mortality <=20
replace bin_mort = 25 if perceived_mortality >20 & perceived_mortality <=30
replace bin_mort = 40 if perceived_mortality >30 & perceived_mortality <=50
replace bin_mort = 50 if perceived_mortality >50 
bys bin_mort: egen bin_mort_worryus_mean=mean(z_worry_corona_econ)
bys bin_mort: egen bin_mort_worryper_mean=mean(z_worry_perecon)
duplicates drop bin_mort, force
keep bin_*
save "$data/temp.dta" , replace

use "$data/survey1_clean.dta", clear
gen bin_cont = 1 if perceived_contagion <=2
replace bin_cont = 3.5 if perceived_contagion >2 & perceived_contagion <=5
replace bin_cont = 7.5 if perceived_contagion >5 & perceived_contagion <=10
replace bin_cont = 15 if perceived_contagion >10 & perceived_contagion <=20
replace bin_cont = 25 if perceived_contagion >20 & perceived_contagion <=30
replace bin_cont = 40 if perceived_contagion >30 & perceived_contagion <=50
replace bin_cont = 50 if perceived_contagion >50 

bys bin_cont: egen bin_cont_worryus_mean=mean(z_worry_corona_econ)
bys bin_cont: egen bin_cont_worryper_mean=mean(z_worry_perecon)

gen bin_mort=bin_cont
duplicates drop bin_cont, force
keep bin_*
merge 1:1 bin_mort using "$data/temp.dta" 
erase "$data/temp.dta" 

keep bin_*

export delimited using "$figures/raw/scatter_plots.csv", replace
